from django.contrib import admin
from apps.resources.models import CarInfoModel, FixedStationInfoModel, TipsInfoModel


# Register your models here.


class CarInfoAdmin(admin.ModelAdmin):
    """
    车辆信息管理类
    """
    list_display = ['id', 'company', 'car_license', 'start_station', 'end_station', 'is_active',
                    'expire_date', 'controller', 'created_time']
    ordering = ('id',)
    fields = ['id', 'company', 'car_license', 'start_station', 'end_station', 'is_active',
              'expire_date', 'controller', 'created_time']
    list_filter = ['id', 'company', 'car_license', 'start_station', 'end_station', 'is_active',
                   'expire_date', 'controller', 'created_time']
    # 外键不能成为搜索字段
    search_fields = ['id', 'company', 'car_license', 'start_station', 'end_station', 'is_active',
                     'expire_date', 'controller', 'created_time']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


class FixedStationInfoAdmin(admin.ModelAdmin):
    """
    固定站点信息管理类
    """
    list_display = ['id', 'car', 'name']
    ordering = ('id',)
    fields = ['id', 'car', 'name']
    list_filter = ['id', 'car', 'name']
    # 外键不能成为搜索字段
    search_fields = ['id', 'car', 'name']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


class TipsInfoAdmin(admin.ModelAdmin):
    """
    提醒信息管理类
    """
    list_display = ['id', 'typeof', 'car', 'text', 'created_time']
    ordering = ('id',)
    fields = ['id', 'typeof', 'car', 'text', 'created_time']
    list_filter = ['id', 'typeof', 'car', 'text', 'created_time']
    # 外键不能成为搜索字段
    search_fields = ['id', 'typeof', 'car', 'text', 'created_time']
    list_per_page = 20
    # 操作记录时，显示选择多少个数
    actions_selection_counter = True


admin.site.register(CarInfoModel, CarInfoAdmin)
admin.site.register(FixedStationInfoModel, FixedStationInfoAdmin)
admin.site.register(TipsInfoModel, TipsInfoAdmin)
